package leetcode.n2022;

import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;

import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * https://leetcode-cn.com/problems/day-of-the-week/
 *
 * @program: brushing
 * @description:
 * @author: LiuQiang
 * @create: 2022-01-03
 **/
public class DayOfTheWeek {

    public String dayOfTheWeek(int day, int month, int year) {


        Map<Integer, String> map = new HashMap<>();
        map.put(0, "Sunday");
        map.put(1, "Monday");
        map.put(2, "Tuesday");
        map.put(3, "Wednesday");
        map.put(4, "Thursday");
        map.put(5, "Friday");
        map.put(6, "Saturday");


        if (month < 3) {
            month += 12;
            year -= 1;
        }
        int c = year / 100;
        year %= 100;
        int D = c / 4 - 2 * c + year + year / 4 + 13 * (month + 1) / 5 + day - 1 + 210;//加上30*7防止出现负数
        return map.get(D % 7);
    }

    public static void main(String[] args) {
        Log log = LogFactory.get();
        DayOfTheWeek dayOfTheWeek = new DayOfTheWeek();


        int day = 2022;
        int month = 1;
        int year = 3;

        log.info(dayOfTheWeek.dayOfTheWeek(day, month, year));
    }
}
